home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cc04.arc / YRSRIGHT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-03-15  |  3.5 KB  |  215 lines

  1. /*
  2.     NetWare Alloy Restore Utility
  3.     V4.42    02/07/84    by Mark Hurst
  4.  
  5.     For use with NetWare V4.n systems
  6.  
  7.     Copyright (C) 1983, 1984 Novell, Inc.
  8. */
  9.  
  10. #include    "ctype.h"
  11. #include    "stdio.h"
  12.  
  13.  
  14. #define LOCALBIT    0x80
  15. #define PERMNET     0x01
  16. #define TEMPNET     0x02
  17. #define NETBITS     0x03
  18.  
  19. #define READBIT     0x01
  20. #define WRITEBIT    0x02
  21. #define OPENBIT     0x04
  22. #define CREATEBIT    0x08
  23. #define DELETEBIT    0x10
  24. #define OWNEDBIT    0x20
  25. #define SEARCHBIT    0x40
  26. #define MODIFYBIT    0x80
  27.  
  28. /* NOTE: the Archive bit was 0x80 on ShareNet V3.12.  Has now changed: */
  29. #define BACKUPBIT    0x20
  30.  
  31.  
  32. #define     VARPATH     '^' - 'A'
  33.  
  34. #define     TRUE        1
  35. #define     FALSE        0
  36.  
  37. extern    FILE    *log;
  38. extern    int    source, target; /* low level I/O file numbers */
  39.  
  40.  
  41. char    *calloc(), *malloc();
  42.  
  43.  
  44. typedef struct dosfcb {
  45.     char    drive;
  46.     char    fname[8];
  47.     char    fext[3];
  48.     unsigned curblk;
  49.     unsigned recsize;
  50.     long    size;
  51.     unsigned date;
  52.     char    reserved[10];
  53.     char    relrec;
  54.     char    record[4];
  55. } FCB;
  56.  
  57. typedef struct exdirfcb {
  58.     char    dummy;
  59.     char    exset;
  60.     char    res[5];
  61.     char    flags;
  62.     char    drive;
  63.     char    fname[8];
  64.     char    fext[3];
  65.     char    gap[17];
  66.     char    size[4];
  67. } ExDirFCB;
  68.  
  69. typedef struct exdosfcb {
  70.     char    dummy;
  71.     char    exset;
  72.     char    res[5];
  73.     char    flags;
  74.     char    drive;
  75.     char    fname[8];
  76.     char    fext[3];
  77.     unsigned curblk;
  78.     unsigned recsize;
  79.     long    size;
  80.     unsigned date;
  81.     char    reserved[10];
  82.     char    relrec;
  83.     char    record[4];
  84. } ExFCB;
  85.  
  86.  
  87. extern    int    listcount;
  88.  
  89. typedef struct    liststruct {
  90.     struct liststruct *link;
  91.     char    name[12]; /* 1 too big for even allocation */
  92.     char    marked;
  93.     char    flags;
  94.     long    size;    /* size of file in bytes */
  95.     unsigned units; /* size of file in allocation units */
  96. } LISTNODE;
  97.  
  98. #define  LISTSIZE    250
  99. extern    LISTNODE *list[LISTSIZE], *curnode;
  100.  
  101. extern    ExFCB    sourcefile;
  102. extern    ExFCB    destfile;
  103.  
  104.  
  105. int    imin();
  106. unsigned umin();
  107. long    lmin();
  108.  
  109.  
  110.  
  111. /*--------*/
  112.  
  113.  
  114. typedef struct setsubstruct {
  115.     int    length;
  116.     char    function;
  117.     char    handle;
  118.     char    grant;
  119.     char    revoke;
  120.     char    speclength;
  121. } SETSUB;
  122.  
  123. typedef struct retsubstruct {
  124.     int    length;
  125. } RETSUB;
  126.  
  127.  
  128. int    SetDirRights (drive, rights)
  129.     char    drive, rights;
  130. {
  131.     SETSUB    set;
  132.     RETSUB    ret;
  133.     char    type;
  134.     int    ccode;
  135.  
  136.     set.length = 5;
  137.     set.function = 4;
  138.     set.handle = GetHandle (drive, &type);
  139.     set.grant = rights;
  140.     set.revoke = 0xFF; /* clear out old rights first */
  141.     set.speclength = 0;
  142.  
  143.     ret.length = sizeof (RETSUB) - 2;
  144.     ccode = dirpath (&set, &ret);
  145.     return (ccode);
  146. }
  147.  
  148. typedef struct gettrust {
  149.     int    length;
  150.     char    function;
  151.     char    handle;
  152.     long    trustee;
  153.     char    mask;
  154.     char    speclength;
  155. } SETTRUST;
  156.  
  157. typedef struct rettrust {
  158.     int    length;
  159. } RETTRUST;
  160.  
  161.  
  162.  
  163. SetTrustee (drive, trustee, rights)
  164.     char    drive;
  165.     long    trustee;
  166.     char    rights;
  167. {
  168.     SETTRUST set;
  169.     RETTRUST ret;
  170.     char    type;
  171.     int    ccode, i;
  172.  
  173.     set.length = 8;
  174.     set.function = 13;
  175.     set.handle = GetHandle (drive, &type);
  176.     set.trustee = trustee;
  177.     set.mask = rights;
  178.     set.speclength = 0;
  179.  
  180.     ret.length = sizeof (RETTRUST) - 2;
  181.     ccode = dirpath (&set, &ret);
  182. }
  183.  
  184.  
  185. static    char    *tptr, *tcptr;
  186.  
  187.  
  188. /* Return 0 if fail to write out trustee rights file, TRUE if OK */
  189.  
  190.  
  191. rrestore (drive, buffer)
  192.     int    drive;
  193.     char    *buffer;
  194. {
  195.     int    actual, TCount, i;
  196.     char    drights;
  197.     long    trustee;
  198.  
  199.     tptr = buffer;
  200.     movmem (tptr, &TCount, 2);
  201.     tptr += 2;
  202.     drights = *tptr ++;
  203.  
  204.     SetDirRights (drive, drights);
  205.  
  206.     for (i = 0; i < TCount; i++ ) {
  207.         movmem (tptr, &trustee, 4);
  208.         tptr += 4;
  209.         drights = *tptr ++;
  210.         SetTrustee (drive, trustee, drights);
  211.     }
  212. }
  213.  
  214.  
  215.